//index.js
//获取应用实例
const app = getApp()
Page({
  data:{
    /*  */
    userInfo_chezhu: null,
    /*  */
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    clicked_alert:false,
    clicked_service: false,
    /*  */
    needAnimation:false,  //对应的页面容器的类名为bx-need_animation
    needAnimationLoad:false, //控制
    menuData:[
      {
        name:'一键报案',
        src:'../../assets/images/index-alert_icon.png',
        hasJG:true,
        isFtype:true,
        phoneCall:true,
        openAnimationLoad:false
      },
      {
        name:'增值服务',
        src:'../../assets/images/index-service_icon.png',
        hasJG:false,
        isFtype:false,
        phoneCall:false,
        card:true,
        openAnimationLoad:false
      }
    ]
  },
  /* 设置animation */
  setNeedAnimation: function(e){
    if(!this.data.userInfo_chezhu.mobile){
      wx.switchTab({
        url: '/pages/personal/personal',
      })
      return
    }
    let { info }  = e.currentTarget.dataset
    /*  */
    if(info.card){
      wx.switchTab({
        url:'/pages/cards/cards'
      })
    }
    /*  */
    if(info.phoneCall){
      //console.log(info.phoneCall)
      wx.makePhoneCall({
        phoneNumber:''+this.data.userInfo_chezhu.kefudianhua,
        success: ()=>{},
        fail: ()=>{}
      })
    }
  },
  onLoad: function () {
  },
  onShow: function(){
    //拿本地用户信息
    this.setData({
      userInfo_chezhu:app.globalData.get_userInfo()
    })
  }
})
